// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.Core.RankEval;

/// <summary>
/// <para>Precision at K (P@k)</para>
/// </summary>
public sealed partial class RankEvalMetricPrecision
{
	/// <summary>
	/// <para>Controls how unlabeled documents in the search results are counted. If set to true, unlabeled documents are ignored and neither count as relevant or irrelevant. Set to false (the default), they are treated as irrelevant.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("ignore_unlabeled")]
	public bool? IgnoreUnlabeled { get; set; }
	[JsonInclude, JsonPropertyName("k")]
	public int? k { get; set; }
	[JsonInclude, JsonPropertyName("relevant_rating_threshold")]
	public int? RelevantRatingThreshold { get; set; }
}

/// <summary>
/// <para>Precision at K (P@k)</para>
/// </summary>
public sealed partial class RankEvalMetricPrecisionDescriptor : SerializableDescriptor<RankEvalMetricPrecisionDescriptor>
{
	internal RankEvalMetricPrecisionDescriptor(Action<RankEvalMetricPrecisionDescriptor> configure) => configure.Invoke(this);

	public RankEvalMetricPrecisionDescriptor() : base()
	{
	}

	private bool? IgnoreUnlabeledValue { get; set; }
	private int? kValue { get; set; }
	private int? RelevantRatingThresholdValue { get; set; }

	/// <summary>
	/// <para>Controls how unlabeled documents in the search results are counted. If set to true, unlabeled documents are ignored and neither count as relevant or irrelevant. Set to false (the default), they are treated as irrelevant.</para>
	/// </summary>
	public RankEvalMetricPrecisionDescriptor IgnoreUnlabeled(bool? ignoreUnlabeled = true)
	{
		IgnoreUnlabeledValue = ignoreUnlabeled;
		return Self;
	}

	public RankEvalMetricPrecisionDescriptor k(int? k)
	{
		kValue = k;
		return Self;
	}

	public RankEvalMetricPrecisionDescriptor RelevantRatingThreshold(int? relevantRatingThreshold)
	{
		RelevantRatingThresholdValue = relevantRatingThreshold;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (IgnoreUnlabeledValue.HasValue)
		{
			writer.WritePropertyName("ignore_unlabeled");
			writer.WriteBooleanValue(IgnoreUnlabeledValue.Value);
		}

		if (kValue.HasValue)
		{
			writer.WritePropertyName("k");
			writer.WriteNumberValue(kValue.Value);
		}

		if (RelevantRatingThresholdValue.HasValue)
		{
			writer.WritePropertyName("relevant_rating_threshold");
			writer.WriteNumberValue(RelevantRatingThresholdValue.Value);
		}

		writer.WriteEndObject();
	}
}